package com.giaothong.http;

import org.json.JSONObject;

import android.content.Context;

import com.giaothong.config.ServerUrl;
import com.giaothong.http.core.HttpAsyncCallback;
import com.giaothong.http.core.HttpConnectionId;
import com.giaothong.http.core.NewHttpConnectionAsync;
import com.giaothong.utils.ALog;
import com.google.android.maps.GeoPoint;

public class HttpSendLocationStatusRequest extends NewHttpConnectionAsync {

	public HttpSendLocationStatusRequest(Context context, HttpAsyncCallback<JSONObject> callback) {
		super(context, HttpConnectionId.SEND_LOCATION_STATUS, callback);
	}

	/**
	 * Call this func to request to server
	 * 
	 * @param pram1
	 * @param param2
	 */
	public void request(GeoPoint location, int status, String userId, String locationName, String locationAddress) {
		// Create json object with data
		rootObj = new JSONObject();

		addParam("latitude", "" + location.getLatitudeE6());
		addParam("longitude", "" + location.getLongitudeE6());
		addParam("status", "" + status);
		addParam("user_id", userId);
		addParam("infomation_name", locationName);
		addParam("address", locationAddress);

		// executable request
		ALog.i("Requests", ServerUrl.SEND_LOCATION_STATUS_URL + "___" + rootObj.toString());
		this.execute(ServerUrl.SEND_LOCATION_STATUS_URL);
	}

}
